package cn.tedu.ivos2.audit.controller;

import cn.tedu.ivos2.audit.pojo.dto.AuditQuery;
import cn.tedu.ivos2.audit.pojo.dto.AuditSaveDTO;
import cn.tedu.ivos2.audit.pojo.vo.AuditVO;
import cn.tedu.ivos2.audit.service.AuditService;
import cn.tedu.ivos2.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/audit/")
@Slf4j
public class AuditController {
    @Autowired
    private AuditService auditService;

    @GetMapping("select")
    public JsonResult selectAudit(AuditQuery auditQuery){
        log.debug("查询审批单参数:{}",auditQuery);
        List<AuditVO> auditList=auditService.select(auditQuery);
        log.debug("查询结果:{}",auditList);
        return JsonResult.ok(auditList);
    }
    @PostMapping("update")
    public JsonResult updateAudit(AuditSaveDTO auditSaveDTO){
        log.debug("更新审批单:{}",auditSaveDTO);
        auditService.update(auditSaveDTO);
        return JsonResult.ok();
    }
}
